import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import path from 'node:path'
import { UnifiedViteWeappTailwindcssPlugin as uvwt } from 'weapp-tailwindcss/vite'

const { isH5, isApp } = require('./shared')
/**
 * @type { import('vite').UserConfig}
 */
export default defineConfig({
	plugins: [
		uni(),
		uvwt({
			rem2rpx: true,
			disabled: isH5 || isApp,
			tailwindcssBasedir: __dirname
		})
	],
	css: {
		postcss: {
			plugins: [
				require('tailwindcss')({
					config: path.resolve(__dirname, './tailwind.config.js')
				}),
				require('autoprefixer')
			]
		}
	}
})
